package com.milk.service.product;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;

import com.milk.model.entity.product.ProductType;
import com.milk.service.product.dao.ProductTypeDao;

import org.springframework.stereotype.Service;

/**
 * productType serviceImpl 2017-09-14 16:57:34 徐政涛
 */
@Service("productTypeService")
public class ProductTypeServiceImpl implements ProductTypeService {

	@Autowired
	private ProductTypeDao productTypeDao;

	public ProductType save(ProductType productType) {
		Assert.notNull(productType, RESULT_NULL + "出错的方法体是saveProductType");
		productTypeDao.save(productType);
		return productType;
	}

	public ProductType update(ProductType productType) throws Exception {
		Assert.notNull(productType, RESULT_NULL + "出错的方法体是updateProductType");
		productTypeDao.update(productType);
		return productType;
	}

	public ProductType getProductTypeById(long productTypeId) {
		ProductType productType = productTypeDao.findById(productTypeId);
		return productType;
	}

	public void deleteProductTypeById(long productTypeId) {
		productTypeDao.deleteById(productTypeId);
	}

	public ProductType getProductTypeByMap(Map<String, Object> params) {
		ProductType productType = productTypeDao.findByMap(params);
		return productType;
	}

	public void deleteProductTypeByMap(Map<String, Object> params) {
		productTypeDao.deleteByMap(params);
	}

	public List<ProductType> queryProductType(Map<String, Object> params) {
		List<ProductType> productTypes = productTypeDao.query(params);
		return productTypes;
	}
}